var fs=require('fs');
module.exports={
	//异步读取文件
	readfile:function(path,recall){
		fs.readFile(path,function(err,data){
			if(err){
				console.log(err);
				throw err;
			}else{
				recall(data.toString());
			}
		})
	},
	//同步读取文件
	readfileSync:function(path){
		var data=fs.readFileSync(path,'utf-8');
		console.log("同步方法执行完毕");
		return data;
	},
	//异步写入文件
	writefile:function(path,content,recall){
		fs.writeFile(path,content,function(err){
			if(err){
				console.log(err);
				throw err;
			}
			recall('写文件成功');
		})
	},
	//同步写入文件
	writefileSync:function(path){
		fs.writeFileSync(path,content);
		console.log('同步写文件完成');
	},
	//异步读取文件流
	readimg:function(path,recall){
		fs.readFile(path,'binary',function(err,filedata){
			if(err){
				console.log(err);
				throw err;
			}else{
				recall(filedata)
			}
			
		})
	},
	//同步读取文件流
	readimgSync:function(path){
		fs.readFileSync(path,content);
		console.log('同步读取文件流');
	},
}
